package com.nami.store.biz.groupmembs.application;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.excel.util.StringUtils;
import com.nami.store.api.request.grpmember.GrpMemberAddReq;
import com.nami.store.api.response.groupmember.GroupMemberDTO;
import com.nami.store.biz.groupmembs.service.GrpMembDomainService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Slf4j
@Service
@RequiredArgsConstructor
public class GrpMembAppServiceImpl implements GrpMembAppService {

    private final GrpMembDomainService membDomainService;

    @Override
    public boolean batchSave(List<GrpMemberAddReq> addRequests) {
        if (CollUtil.isEmpty(addRequests)) {
            return false;
        }
        return membDomainService.batchSave(addRequests);
    }

    @Override
    public GroupMemberDTO getGrpMemberByGrpIdAndUserId(String grpId, String userId) {
        if (StringUtils.isBlank(grpId) || StringUtils.isBlank(userId)) {
            return null;
        }
        return membDomainService.getGrpMembersByGrpIdAndUserId(grpId, userId);
    }

    @Override
    public List<GroupMemberDTO> getGrpMembers(String grpId) {
        if (StringUtils.isBlank(grpId)) {
            return null;
        }
        return membDomainService.getGrpMembers(grpId);
    }

    @Override
    public List<GroupMemberDTO> getGrpMembersExceptMe(String grpId, String userId) {
        if (StringUtils.isBlank(grpId) || StringUtils.isBlank(userId)) {
            return null;
        }
        return membDomainService.getGrpMembersExceptMe(grpId, userId);
    }

    @Override
    public List<GroupMemberDTO> getGrpMembsByGrpIdAndUserIds(String grpId, List<String> userIds) {
        if (StringUtils.isBlank(grpId ) || CollUtil.isEmpty(userIds)) {
            return null;
        }
        return  membDomainService.getGrpMembsByGrpIdAndUserIds(grpId, userIds);
    }

    @Override
    public Map<String, GroupMemberDTO> getGrpMembsByUserIds(String grpId, List<String> userIds) {
        return membDomainService.getGrpMembsByUserIds(grpId, userIds);
    }


}
